<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="utf-8"%>
<%@ page import="org.vo.*,org.factory.*,org.dao.*" %>
<%@ page import="java.text.DateFormat,java.util.Date"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<% request.setCharacterEncoding("utf-8"); %>
<title>提交注册</title>
</head>
<body>
  <% 
   User user=new User();
   user.setName(request.getParameter("name"));
   user.setSex(request.getParameter("gender"));
   user.setAge(Integer.parseInt(request.getParameter("age")));
   user.setMail(request.getParameter("mail"));
   user.setPasswd(request.getParameter("passwd"));
   user.setDate(DateFormat.getDateInstance().format(new Date())); //让注册日期等于当前日期
   UserDAO dao=DAOFactory.getUserDAOInstance();
   boolean flag=dao.doCreate(user);            //执行insert语句后user.getId()竟然获得了自动插入的自增的id，真是神奇，应该和User的配置文件有关吧？
   if(flag){
	     
  %>
    <script type="text/javascript">
       alert("注册成功，id是"+<%=user.getId()%>+",马上去的登录吧"); 
      <% response.setHeader("Refresh", "0;URL=login.jsp");%>
 
    </script>
  <% 
   }
   %>
</body>
</html>